package jenum.com;

import com.sun.corba.se.impl.presentation.rmi.ExceptionHandler;

/**
 * Created by as on 2016/11/17.
 */
public class ThrowsEx {
    public static void main(String[] args) {
        BookInfo bookInfo = new BookInfo();
        String[] bookname = {"java", "php"};
        double[] bookPrice = {550, 600};
        try {
            bookInfo.showName(bookname);
            bookInfo.showPrice(bookPrice);
        }
        catch (ArrayIndexOutOfBoundsException E){
            ExceptionHandlers.arrayIndex();
        }
        catch (Exception e){
            ExceptionHandlers.exception();
        }
    }
}

class BookInfo{
    void showName(String[] name) throws ArrayIndexOutOfBoundsException{
        System.out.println(name[2]);
    }
    void showPrice(double[] price) throws ArrayIndexOutOfBoundsException{
        System.out.println(price[2]);
    }
}

class ExceptionHandlers{
    public static void arrayIndex(){
        System.out.println("索引超出范围");
    }

    public static void exception()
    {
        System.out.print("异常事件");
    }
}
